// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   DecodeStarDict.java

import java.io.*;
import java.util.ArrayList;

public class DecodeStarDict {

	public DecodeStarDict() {
	}

	public static byte[] charToByte(char c) {
		int i = c;
		byte abyte0[] = new byte[2];
		for (int j = abyte0.length - 1; j > -1; j--) {
			abyte0[j] = (new Integer(i & 0xff)).byteValue();
			i >>= 8;
		}

		return abyte0;
	}

	public static int byteToInt(byte abyte0[]) {
		int i = 0;
		for (int j = 0; j < 3; j++) {
			if (abyte0[j] >= 0)
				i += abyte0[j];
			else
				i = i + 256 + abyte0[j];
			i *= 256;
		}

		if (abyte0[3] >= 0)
			i += abyte0[3];
		else
			i = i + 256 + abyte0[3];
		return i;
	}

	public static void main(String args[]) {
		if (args.length != 3) {
			System.out
					.println("Usage:\n\tjava DecodeStarDict idxfile dictfile outputfile");
			System.exit(0);
		}
		BufferedWriter bufferedwriter = null;
		RandomAccessFile randomaccessfile = null;
		RandomAccessFile randomaccessfile1 = null;
		try {
			File file = new File(args[2]);
			randomaccessfile = new RandomAccessFile(args[0], "r");
			randomaccessfile1 = new RandomAccessFile(args[1], "r");
			OutputStreamWriter outputstreamwriter = new OutputStreamWriter(
					new FileOutputStream(file), "UTF-8");
			bufferedwriter = new BufferedWriter(outputstreamwriter);
		} catch (Exception exception) {
			exception.printStackTrace();
		}
		ArrayList arraylist = new ArrayList(50);
		boolean flag = false;
		String s = "";
		int j = 0;
		try {
			do {
				int i;
				if ((i = randomaccessfile.read()) == -1)
					break;
				if (i != j)
					arraylist.add(Integer.valueOf(i));
				if (i == j) {
					byte abyte0[] = new byte[arraylist.size()];
					for (int i1 = 0; i1 < arraylist.size(); i1++)
						abyte0[i1] = (byte) Integer.parseInt(arraylist.get(i1)
								.toString());

					String s1 = new String(abyte0, "UTF-8");
					bufferedwriter.write(s1, 0, s1.length());
					bufferedwriter.newLine();
					int k = randomaccessfile.readInt();
					int l = randomaccessfile.readInt();
					byte abyte1[] = new byte[l];
					randomaccessfile1.readFully(abyte1, 0, l);
					s1 = new String(abyte1, "UTF-8");
					bufferedwriter.write(s1, 0, s1.length());
					bufferedwriter.newLine();
					bufferedwriter.write("</>", 0, 3);
					bufferedwriter.newLine();
					arraylist.clear();
				}
			} while (true);
		} catch (IOException ioexception) {
			ioexception.printStackTrace();
		}
		try {
			randomaccessfile.close();
			randomaccessfile1.close();
			bufferedwriter.close();
		} catch (IOException ioexception1) {
			ioexception1.printStackTrace();
		}
	}
}
